local skel = fk.CreateSkill {
  name = "emo__tongxin",
  tags = {Skill.Limited, Skill.Permanent},
}

Fk:loadTranslationTable{
  ["emo__tongxin"] = "同心",
  [":emo__tongxin"] = "持恒技，限定技，当有“主”标记的角色死亡时，你可以令其进入一轮修整，然后你进入一轮修整。",
  ["#emo__tongxin-invoke"] = "同心：你可以令你与 %src 一起修整一轮！",

  ["$emo__tongxin1"] = "夏生先生……我喜欢你",
  ["$emo__tongxin2"] = "欢迎回来，夏生先生",
}

skel:addEffect(fk.BeforeGameOverJudge, {
  can_trigger = function(self, event, target, player, data)
    return target.id == player:getMark("emo__renzhu_tar") and player:hasSkill(skel.name) and target.rest == 0
    and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function (self, event, target, player, data)
    if player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#emo__tongxin-invoke:"..target.id} ) then
      event:setCostData(self, { tos = {target} })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    target._splayer:setDied(false)
    room:setPlayerRest(target, 1)
    -- 让自己死亡并进入休整，然后结束自己的回合
    room:setPlayerRest(player, 1)
    player.dead = true
    table.removeOne(room.alive_players, player) -- 这个竟然能同步给客户端，神奇
    room:broadcastProperty(player, "dead")
    if player == room.current then
      room:endTurn()
    end
  end,
})

return skel
